//
//  AppDelegate.m
//  MangoTest
//
//  Created by 胡超 on 2021/8/28.
//

#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

- (NSString *)MGTransformPinYin(NSString *)str {
    CFMutableStringRef cfStr = CFStringCreate
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    NSString *pinyin = MGTransformPinYin(@"我的");
    NSLog(@"%@",pinyin);
    return YES;
}

- (NSString *)pinyinStr:(NSString *)str {
    if (str.length > 0) {
        NSMutableString *pinyin = [str mutableCopy];
        CFStringTransform((__bridge CFMutableStringRef)pinyin, NULL, kCFStringTransformMandarinLatin, NO);
        CFStringTransform((__bridge CFMutableStringRef)pinyin, NULL, kCFStringTransformStripDiacritics, NO);
        return [pinyin stringByReplacingOccurrencesOfString:@" " withString:@""];
    }
    return str;
}

- (NSString *)pinyinFirstWord:(NSString *)str {
    if (str.length > 0) {
        NSMutableString *pinyin = [[str substringToIndex:1] mutableCopy];
        CFStringTransform((__bridge CFMutableStringRef)pinyin, NULL, kCFStringTransformMandarinLatin, NO);
        CFStringTransform((__bridge CFMutableStringRef)pinyin, NULL, kCFStringTransformStripDiacritics, NO);
        return [pinyin substringToIndex:1].uppercaseString;
    }
    return str;
}

@end
